package com.easyedu.core.dao;

import com.easyedu.core.entity.po.ResidenceHalls;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author mengranliu
 * @date 2022/3/13
 */
@Mapper
public interface ResidenceHallsDao {

     @Select("select * from residence_halls where halls_id in (select halls_id from "
             + "department_residence_halls_relation where department_id =#{departmentId} )")
     List<ResidenceHalls> getDepartmentHalls(long departmentId);

     @Select("select  * from residence_halls")
     List<ResidenceHalls> getHalls();

     @Select("select * from residence_halls where halls_name = #{buildName}")
     ResidenceHalls getByName(String buildName);

     @Insert("insert into residence_halls set halls_name = #{buildName} ,X = #{x},Y = #{y}")
     Integer add(String buildName, double x, double y);

     @Select("select * from residence_halls where halls_id = #{buildingId}")
     ResidenceHalls getById(int buildingId);

     @Update("update residence_halls set halls_name = #{buildName} ,X = #{x},Y = #{y} where halls_id = #{buildingId}")
     Integer updateById(int buildingId, String buildName, double x, double y);

     @Delete("delete from residence_halls where halls_id = #{buildingId}")
     Integer deleteById(int buildingId);
}
